home *** CD-ROM | disk | FTP | other *** search
- From: Valentin Bonnard <bonnardv@pratique.fr>
- Message-ID: <4eqr6b$778@s3.iway.fr>
- X-Original-Date: 1 Feb 1996 16:53:30 GMT
- Path: in2.uu.net!bounce-back
- Date: 01 Feb 96 17:10:01 GMT
- Approved: fjh@cs.mu.oz.au
- Return-Path: <news@iway.fr>
- Newsgroups: comp.std.c++
- Subject: Re: Give operator. a chance
- Organization: Internet Way
- References: <3102AD11.1663@et.se> <4e0pj1$rq6@news.bridge.net> <9601260532.14152@mulga.cs.mu.OZ.AU>
- X-Mailer: Mozilla 1.1N (Macintosh; I; 68K)
- X-Url: news:9601260532.14152@mulga.cs.mu.OZ.AU
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMRD0FOEDnX0m9pzZAQFgAAF9GPrmSgpuprhbtVKUoXv6Cf+OdNHN1xZY
- vZfpf9rqdE3p0N/9oGkp+Ky4E9Z1VO70
- =3Ps8
-
- First of all, I suppose there is no difference bewten A + B, A.operator+ (B)
- and A.plus (B) when operator+ is defined as plus.
-
- Suppose first you overload operator+, then you overload operator. in MyClass:
-
- class MyClass {
- private:
- AnnotherClass* theOtherClass;
- public:
- AnnotherClass operator. ();
- MyClass operator+ (int);
- void Something_only_defined_in_MyClass ();
- };
-
- MyClass A;
-
- A + 2; is equivalent with A.operator (2) and (A.operator.).operator (2)
-
- You can't even write (&A)->Something_only_defined_in_MyClass () in order to
- access Something_only_defined_in_MyClass (which is only defined for MyClass):
- (&A)->a_member is equivalent with ((A.operator.).operator&)->a_member.
-
- How can yu access Something_only_defined_in_MyClass ?
-
- If operator. return theOtherClass, why don't you just write:
- AnnotherClass* theOtherClass;
-
- theOtherClass + 2;
-
- Note that A.m _is equivalent_ (provided that operator. is not overloaded in
- AnnotherClass) with (&A)->m.
-
- Valentin Bonnard
- bonnardv@pratique.fr
- ---
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
- is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
-